﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace SynoManager.GUI
{
    /// <summary>
    /// Interface that should be implemented by all plugins that want to be a part of the graphical user interface.
    /// </summary>
    public interface IGuiPlugin
    {
        /// <summary>
        /// Initializes the plugin, enabling it to hook on the graphical user interface
        /// </summary>
        /// <param name="host">Structure containing references to the different parts of the interface.</param>
        /// <remarks>This function is probably called only once in the life time of the plugin</remarks>
        void InitializeHost(IHost host);

        /// <summary>
        /// Initializes the plugin, enabling it to hook on the events of the device or it's services.
        /// </summary>
        /// <param name="device">The device for which the initialize.</param>
        /// <remarks>It will called upon every new connection of a device, so it is possible it will be called multiple times per lifetime of a plugin.</remarks>
        void Initialize(SynoDevice device);

        /// <summary>
        /// Function that is called by the Preference Form to populate the treeview
        /// </summary>
        /// <param name="treeView">Treeview where the plugin can add it's node(s). <see cref="TreeNode.Tag" /> should contain PreferencePanel.</param>
        void PopulatePreferencesForm(TreeViewEx treeView);

        /// <summary>
        /// Function that is called when the connection state has changed
        /// </summary>
        /// <param name="isConnected">Returns true if the device is connected.</param>
        /// <param name="wasConnected">Returns true if the device has successfully connected in the past</param>
        /// <remarks>This function is called in a thread-safe way, so no Invoke is required.</remarks>
        void OnConnectionStateChange(bool isConnected, bool wasConnected);

        //TODO: Plugin Control/Tab Properties should be refactored in some kind of interface
        // I think a plugin should be able to expose more than one 'maincontrol' or Tab, and each of these should have it's own TabActive-property (or event!?)

        /// <summary>
        /// Gets the main control.
        /// </summary>
        /// <value>The main control of the interface.</value>
        Control MainControl { get; }
        /// <summary>
        /// Sets a value indicating whether the tab is active.
        /// </summary>
        bool TabActive { set; }

        /// <summary>
        /// Gets the priority the tabcontrol order
        /// </summary>
        int TabPriority { get; }
    }
}
